package com.my.study.util;

import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author: yidujun
 * @create: 2021/11/08 15:37
 */
@Slf4j
public final class IpUtils {

    private IpUtils() {
    }

    public static String getLocalIp() {
        InetAddress address = null;
        try {
            address = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            log.error("获取本机ip错误...", e);
            e.printStackTrace();
        }
        return address == null ? null : address.getHostAddress();
    }

}
